"""


"""

from flask import Blueprint
# 1、创建蓝图对象
from flask import redirect
from flask import request
from flask import session
from flask import url_for

admin_blu = Blueprint("admin", __name__, url_prefix="/admin")

from . import views


@admin_blu.before_request
def admin_blu_before_request():
    # 普通用户只能访问后台的登录页面，不能访问后台其他的页面
    is_admin = session.get("is_admin", False)
    # 还要加一个条件，它访问的不是登录login页面
    if not is_admin and not request.url.endswith("/admin/login"):
        return redirect(url_for("index.index"))